import request from "@/utils/request";

// 用户分页查询
export const queryPageApi = (params) =>
  request.get("/users", { params: params });

// 根据ID查询用户
export const queryByIdApi = (id) => request.get(`/users/${id}`);

// 新增用户
export const addApi = (data) => request.post("/users", data);

// 修改用户
export const updateApi = (data) => request.put("/users", data);

// 删除用户
export const deleteApi = (ids) => request.delete(`/users/${ids}`);

// 查询所有部门
export const queryDeptListApi = () => request.get("/depts/list");

// 查询所有角色
export const queryRoleListApi = () => request.get("/roles/list");

// 文件上传
export const uploadApi = (file) => {
  const formData = new FormData();
  formData.append("image", file);
  return request.post("/upload", formData, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
};
